package edu.cuit.project.domain;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import org.hibernate.annotations.GenericGenerator;

/**
 * Expert entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "expert", catalog = "db_project")
public class Expert implements java.io.Serializable {

	// Fields

	private String id;
	private AddressArea addressArea;
	private Qualification qualification;
	private Department department;
	private Nation nation;
	private String name;
	private Date birthday;
	private Integer gender=0;
	private String cellphonenum;
	private String career;
	private String idcard;
	private Integer politicalStatus=0;
	private Integer marriageStatus=0;
	private String address;
	private Integer education=0;
	private Integer state=0;
	private Set<Expertteam> expertteams = new HashSet<Expertteam>(0);
	private Set<Evaluate> evaluates = new HashSet<Evaluate>(0);

	// Constructors

	/** default constructor */
	public Expert() {
	}

	/** full constructor */
	public Expert(AddressArea addressArea, Qualification qualification,
			Department department, Nation nation, String name, Date birthday,
			Integer gender, String cellphonenum, String career, String idcard,
			Integer politicalStatus, Integer marriageStatus, String address,
			Integer education, Integer state, Set<Expertteam> expertteams,
			Set<Evaluate> evaluates) {
		this.addressArea = addressArea;
		this.qualification = qualification;
		this.department = department;
		this.nation = nation;
		this.name = name;
		this.birthday = birthday;
		this.gender = gender;
		this.cellphonenum = cellphonenum;
		this.career = career;
		this.idcard = idcard;
		this.politicalStatus = politicalStatus;
		this.marriageStatus = marriageStatus;
		this.address = address;
		this.education = education;
		this.state = state;
		this.expertteams = expertteams;
		this.evaluates = evaluates;
	}

	// Property accessors
	@GenericGenerator(name = "generator", strategy = "uuid")
	@Id
	@GeneratedValue(generator = "generator")
	@Column(name = "id", unique = true, nullable = false, length = 36)
	public String getId() {
		return this.id;
	}

	public void setId(String id) {
		this.id = id;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "area_id")
	public AddressArea getAddressArea() {
		return this.addressArea;
	}

	public void setAddressArea(AddressArea addressArea) {
		this.addressArea = addressArea;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "qualification_id")
	public Qualification getQualification() {
		return this.qualification;
	}

	public void setQualification(Qualification qualification) {
		this.qualification = qualification;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "department_id")
	public Department getDepartment() {
		return this.department;
	}

	public void setDepartment(Department department) {
		this.department = department;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "nation_id")
	public Nation getNation() {
		return this.nation;
	}

	public void setNation(Nation nation) {
		this.nation = nation;
	}

	@Column(name = "name", length = 30)
	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Temporal(TemporalType.DATE)
	@Column(name = "birthday", length = 10)
	public Date getBirthday() {
		return this.birthday;
	}

	public void setBirthday(Date birthday) {
		this.birthday = birthday;
	}

	@Column(name = "gender")
	public Integer getGender() {
		return this.gender;
	}

	public void setGender(Integer gender) {
		this.gender = gender;
	}

	@Column(name = "cellphonenum", length = 30)
	public String getCellphonenum() {
		return this.cellphonenum;
	}

	public void setCellphonenum(String cellphonenum) {
		this.cellphonenum = cellphonenum;
	}

	@Column(name = "career")
	public String getCareer() {
		return this.career;
	}

	public void setCareer(String career) {
		this.career = career;
	}

	@Column(name = "idcard", length = 30)
	public String getIdcard() {
		return this.idcard;
	}

	public void setIdcard(String idcard) {
		this.idcard = idcard;
	}

	@Column(name = "political_status")
	public Integer getPoliticalStatus() {
		return this.politicalStatus;
	}

	public void setPoliticalStatus(Integer politicalStatus) {
		this.politicalStatus = politicalStatus;
	}

	@Column(name = "marriage_status")
	public Integer getMarriageStatus() {
		return this.marriageStatus;
	}

	public void setMarriageStatus(Integer marriageStatus) {
		this.marriageStatus = marriageStatus;
	}

	@Column(name = "address")
	public String getAddress() {
		return this.address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	@Column(name = "education")
	public Integer getEducation() {
		return this.education;
	}

	public void setEducation(Integer education) {
		this.education = education;
	}

	@Column(name = "state")
	public Integer getState() {
		return this.state;
	}

	public void setState(Integer state) {
		this.state = state;
	}

	@ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "experts")
	public Set<Expertteam> getExpertteams() {
		return this.expertteams;
	}

	public void setExpertteams(Set<Expertteam> expertteams) {
		this.expertteams = expertteams;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "expert")
	public Set<Evaluate> getEvaluates() {
		return this.evaluates;
	}

	public void setEvaluates(Set<Evaluate> evaluates) {
		this.evaluates = evaluates;
	}

	@Override
	public String toString() {
		return this.name;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Expert other = (Expert) obj;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		return true;
	}

}